import {Module} from 'vuex'
// import cn from 'ant-design-vue/es/locale/zh_CN'

import zh_CN from 'ant-design-vue/es/locale/zh_CN'
import en_US from 'ant-design-vue/es/locale/en_US'
import zh_TW from 'ant-design-vue/es/locale/zh_TW'

const locales = {zh_TW, zh_CN, en_US}

type key = keyof typeof locales

import config from '../config/app.config'

const basic: Module<any, any> = {
  namespaced: true,
  state: () => ({
    isLoggedIn: false,
    isCollapse: false,
    locale: zh_CN,
    username: 'arlo',
    title: config.setting.title,
    mapLoaded: false,
  }),
  mutations: {
    flip: (state) => state.isCollapse = !state.isCollapse,
    changeLocale: (state, locale: string) => state.locale =  locales[locale as key]
  },
  getters: {
    login: state => state.isLoggedIn
  },
}


export default basic
